def isPrime(num):
    if num < 2:
        return False
    for i in range(2, int(num ** 0.5)+1):
        if num % i == 0:
            return False
    return True

cnt = 0
for i in range(1, 20001):
    if isPrime(i):

        if cnt % 5 == 0 and cnt != 0:
            print(i)
        else:
            print(i, end=' ')
        cnt += 1
